import java.util.Scanner;
import java.util.*;

public class MC0350小码哥请吃饭 {
    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        // code here
        int n = input.nextInt();
        int m = input.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = input.nextInt();
        }
        Arrays.sort(arr);
        System.out.println(arr[n-m]);
        input.close();
    }
}
